'****************************************************************************'
'                                                                            '
' Copyright (C) 2010 Muhammad alaa                                           '
'                                                                            '
' This program is free software; you can redistribute it and/or modify       '
' it under the terms of the GNU General Public License as published by       '
' the Free Software Foundation; either version 2 of the License, or          '
' (at your option) any later version.                                        '
'                                                                            '
' This program is distributed in the hope that it will be useful,            '
' but WITHOUT ANY WARRANTY; without even the implied warranty of             '
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              '
' GNU General Public License for more details.                               '
'                                                                            '
' You should have received a copy of the GNU General Public License along    '
' with this program; if not, write to the Free Software Foundation, Inc.,    '
' 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                '
'                                                                            '
'****************************************************************************'

Namespace API

    Public NotInheritable Class HeapAPI
        Private Sub New()
        End Sub

        Public Declare Function GetProcessHeap Lib "kernel32.dll" () As IntPtr
        Public Declare Function GetProcessHeaps Lib "kernel32.dll" (ByVal NumberOfHeaps As UInteger, <MarshalAs(UnmanagedType.LPArray)> ByRef ProcessHeaps() As IntPtr) As UInteger
        Public Declare Function HeapAlloc Lib "kernel32.dll" (ByVal hHeap As IntPtr, ByVal dwFlags As UInteger, ByVal dwBytes As UInteger) As IntPtr
        Public Declare Function HeapCompact Lib "kernel32.dll" (ByVal hHeap As IntPtr, ByVal dwFlags As UInteger) As UInteger
        Public Declare Function HeapCreate Lib "kernel32.dll" (ByVal flOptions As UInteger, ByVal dwInitialSize As UInteger, ByVal dwMaximumSize As UInteger) As IntPtr
        Public Declare Function HeapDestroy Lib "kernel32.dll" (ByVal hHeap As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
        Public Declare Function HeapFree Lib "kernel32.dll" (ByVal hHeap As IntPtr, ByVal dwFlags As UInteger, ByVal lpMem As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
        Public Declare Function HeapLock Lib "kernel32.dll" (ByVal hHeap As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
        Public Declare Function HeapQueryInformation Lib "kernel32.dll" (ByVal HeapHandle As IntPtr, ByVal HeapInformationClass As Integer, ByRef HeapInformation As IntPtr, ByVal HeapInformationLength As UInteger, ByRef ReturnLength As UInteger) As <MarshalAs(UnmanagedType.Bool)> Boolean
        Public Declare Function HeapReAlloc Lib "kernel32.dll" (ByVal hHeap As IntPtr, ByVal dwFlags As UInteger, ByVal lpMem As IntPtr, ByVal dwBytes As UInteger) As IntPtr
        Public Declare Function HeapSetInformation Lib "kernel32.dll" (ByVal HeapHandle As IntPtr, ByVal HeapInformationClass As Integer, ByRef HeapInformation As IntPtr, ByVal HeapInformationLength As UInteger) As <MarshalAs(UnmanagedType.Bool)> Boolean
        Public Declare Function HeapSize Lib "kernel32.dll" (ByVal hHeap As IntPtr, ByVal dwFlags As UInteger, ByVal lpMem As IntPtr) As UInteger
        Public Declare Function HeapUnlock Lib "kernel32.dll" (ByVal hHeap As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
        Public Declare Function HeapValidate Lib "kernel32.dll" (ByVal hHeap As IntPtr, ByVal dwFlags As UInteger, ByVal lpMem As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
        Public Declare Function HeapWalk Lib "kernel32.dll" (ByVal hHeap As IntPtr, ByRef lpEntry As PROCESS_HEAP_ENTRY) As <MarshalAs(UnmanagedType.Bool)> Boolean
    End Class

End Namespace

